package com.wxw.gulidemo.schedule;/**
 * @author by xxz
 * @date 2022/6/21
 */

import cn.hutool.core.date.DateUtil;
import com.wxw.gulidemo.service.IStatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Description

 * @author by xxz

 * @date 2022/6/21

 * @throws
 */
@Component
public class ScheduledTask {

    @Autowired
    private IStatisticsDailyService statisticsDailyService;

    //定时任务 -- 每天凌晨1点运行(将前一天的注册人数统计到表中)
    @Scheduled(cron = "0 0 1 * * ? ")
    public void task02(){
        statisticsDailyService.createStatisticsByDay(DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1)));
    }

}
